package com.longcai.cm.base.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableSwaggerBootstrapUi;
import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUi
@Profile("dev")
public class SwaggerConfiguration {


    @Bean(value = "portalApi")
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("农商行")
                .select()
                //要用sprongBoot内置的sweeager必须改括号里的路径）
                .apis(RequestHandlerSelectors.basePackage("com.longcai.cm.api"))
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("longcai-cm 接口文档 ")
                .description("longcai-cm-fuzhou-magua")
                .termsOfServiceUrl("http://localhost:4002/CM-API/doc.html")
                //要用springBoot内置的swagger必须改这里的端口与yml文件一致）
                .contact(new Contact("longcai", "www.baidu.com", "1148017805@qq.com"))
                .version("1.0")
                .build();
    }
}